<%--
  Created by IntelliJ IDEA.
  User: zhangDongFei
  Date: 2020/11/26
  Time: 14:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>基本资料</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css" charset="GBK">
    <%--<script src="${pageContext.request.contextPath}/jquery-3.5.1.min.js" charset="GBK"></script>--%>
    <script src="${pageContext.request.contextPath}/layui/layui.js"></script>
    <%--<link href="${pageContext.request.contextPath}/toastr-master/toastr.min.css" rel="stylesheet"/>
    <script src="${pageContext.request.contextPath}/toastr-master/toastr.min.js" charset="GBK"></script>--%>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
    <script src="${pageContext.request.contextPath}/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.9.0.min.js"></script>
</head>
<style>
    #left {
        float: left;
        width: 50%;
    }

    #right {
        float: left;
        width: 40%;
        /*border: 1px solid red;*/
        margin-top: 10px;
    }
    #jb{
       /* border:1px solid red;*/
        width: 350px;
        float: left;
    }
    #tu{
        border: 1px solid gray;
        width: 80px;
        height: 80px;
        float: left;

    }
</style>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>个人信息</legend>
</fieldset>
<div id="left">
    <div class="layui-card">
        <div class="layui-card-header">可修改信息</div>
        <div class="layui-card-body">
            <form class="layui-form" lay-filter="updateInformation" id="updateInformation">

                <hr class="layui-bg-green">
                <input type="text" style="display: none" name="id" value="${id}">

                <div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">手机号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="tel" class="layui-input" lay-verify="required">
                    </div>
                </div>
                <div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">地址</label>
                    <div class="layui-input-inline">
                        <textarea type="text" name="address" class="layui-input" lay-verify="required"></textarea>
                    </div>
                </div>
                <br>
                <div class="layui-form-item layui-col-md-offset4" style="margin-top: 5px">
                    <button lay-submit lay-filter="updateBtn" class="layui-btn">修改资料</button>
                </div>
            </form>
        </div>
    </div>
</div>
<div id="right">
    <div class="layui-card">
        <div class="layui-card-header">基本信息</div>
        <hr class="layui-bg-green">
         <div id="tu">
                <img src="${imgpath}" width="80px" height="80px"/>
            </div>
        <div class="layui-card-body" id="jb">
            <form class="layui-form" lay-filter="information" id="information" style="margin-top: 5px">
                <div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">编号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="id" class="layui-input" disabled>
                    </div>
                </div>

                <div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="sname" class="layui-input" disabled>
                    </div>
                </div>

                <div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">所属部门</label>
                    <div class="layui-input-inline ">
                        <input type="text" name="dname" class="layui-input" disabled>
                    </div>
                </div>

                <div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">入职时间</label>
                    <div class="layui-input-inline ">
                        <input type="text" name="rzdate" class="layui-input" disabled>
                    </div>
                </div>

                <%--<div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">职位</label>
                    <div class="layui-input-inline ">
                        <input type="text" name="dname" class="layui-input" disabled>
                    </div>
                </div>--%>

                <div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">手机号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="tel" class="layui-input" disabled>
                    </div>
                </div>

                <div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">身份证号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="idcard" class="layui-input" disabled>
                    </div>
                </div>

                <div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">地址</label>
                    <div class="layui-input-inline">
                        <textarea type="text" name="address" class="layui-input" disabled></textarea>
                    </div>
                </div>

            </form>
        </div>
    </div>
</div>

</body>
<script>
    layui.use(['upload', 'form','jquery'], function () {
        var $ = layui.jquery;
        var upload = layui.upload;
        var form = layui.form;
        $(function () {

            getInformation();


        })

        // 发送ajax请求当前登录人的信息
        function getInformation() {
            var id=${id}
            $.ajax({
                url: '${pageContext.request.contextPath}/geren',
                type: 'post',
                data:{id:id},
                async: false,
                dataType:'JSON',
                success: function (result) {
                    //alert(JSON.stringify(result))
                    form.val('information', (result))
                    form.val('updateInformation', result)
                    //$('#demo1').attr('src',result.imgpath );
                }
            })

        }

        //修改手机号的地址表单提交
        form.on('submit(updateBtn)', function (data) {
            $.ajax({
                url: '${pageContext.request.contextPath}/xiugai',
                data: data.field,
                async: false,
                type: 'post',
                dataType: 'JSON',
                success: function (result) {
                    if (result > 0) {
                        getInformation();
                        layer.msg("修改成功");
                    } else {
                        layer.msg("修改失败")
                    }
                }
            })
            return false;
        })


    })
</script>
</html>

